package com.starblink.android.basic.btmnavanim


/**
 * 磁盘/内存存储key定义
 */
object BtmNavAnimControl {
//    var navAnimControl : NavAnimSub =
//        NavAnimSub()
//    lateinit var navAnimObs : NavAnimObs

    var subMaps: HashMap<String, NavAnimSub> = hashMapOf()
    var obsMaps: HashMap<String, NavAnimObs> = hashMapOf()
    private var scrollViewListener: ScrollViewListener? = null

    //dy大于0 上拉
    //小于0 下拉
    fun animControlAddSub(pageTag: String) {
        val sub = NavAnimSub()
        val obs = NavAnimObs(sub)
        subMaps[pageTag] = sub
        obsMaps[pageTag] = obs
    }

    fun removeSub(pageTag: String){
        subMaps[pageTag]?.removeObserver(obsMaps[pageTag])
    }

    fun setControlData(pageTag: String, dy: Int) {
        scrollViewListener?.onScrollChanged(pageTag, dy)
    }

    interface ScrollViewListener {
        fun onScrollChanged(pageTag: String, dy: Int)
    }

    fun setScrollViewListener(scrollViewListener: ScrollViewListener) {
        this.scrollViewListener = scrollViewListener
    }

}